import axios from "axios"

axios.defaults.baseURL = "/api"
axios.defaults.timeout = 6000
const instance = axios.create({
        baseURL: '/api',
        timeout: 4000
    })
    // 请求拦截器
instance.interceptors.request.use(config => {
    let token = localStorage.getItem('token')
    const isToken = (config.headers || {}).isToken
    token && (config.headers.xczAuthorization = token)
    console.log('config=',config)
    return config
}, error => {

})

// 响应拦截器
instance.interceptors.response.use(response => {
    return response.data
}, error => {

})
export const req_post = (url, params) => instance.post(url, params)
export const req_get = (url, params) => instance.get(url, { params })